package homework0713;

import testGUI.Util;

import javax.imageio.metadata.IIOMetadataFormatImpl;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;

public class PlayGUI extends JFrame {

    public PlayGUI() {
        PlayRich playRich = new PlayRich();
        playRich.init();
        playRich.xipai();
        playRich.send();


        playRich.sort(playRich.player1);
        playRich.sort(playRich.player2);
        playRich.sort(playRich.player3);

        System.out.println(playRich.player1);


        this.setLayout(null);
        String dizhi = "/images/";
        int a = 600;
        for (int i = 0; i < playRich.player1.size(); i++) {
            dizhi += playRich.player1.get(i) + ".jpg";
            Icon titleimage = Util.getimagesIcon(dizhi);
            JLabel label1 = new JLabel(titleimage);
            label1.setBounds(10, a, 105, 150);
            this.add(label1);
            System.out.println(dizhi);
            a -= 40;
            dizhi = "/images/";
        }

        int b = 600;
        for (int i = 0; i < playRich.player2.size(); i++) {
            dizhi += playRich.player2.get(i) + ".jpg";
            Icon titleimage = Util.getimagesIcon(dizhi);
            JLabel label1 = new JLabel(titleimage);
            label1.setBounds(900, b, 105, 150);
            this.add(label1);
            System.out.println(dizhi);
            b -= 40;
            dizhi = "/images/";
        }
        int c = 780;
        for (int i = 0; i < playRich.player3.size(); i++) {
            dizhi += playRich.player3.get(i) + ".jpg";
            Icon titleimage = Util.getimagesIcon(dizhi);
            JLabel label1 = new JLabel(titleimage);
            label1.setBounds(c, 600, 105, 150);
            this.add(label1);
            System.out.println(dizhi);
            c -= 40;
            dizhi = "/images/";
        }


        this.setSize(1100, 1000);
        this.setTitle("斗地主");
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.setLocationRelativeTo(null);
        this.setVisible(true);


    }

    public static void main(String[] args) {
        new PlayGUI();

    }
}
